---
category: Misc
created: '2020-04-23'
title: Get the value of a param from a URL
updated: '2021-10-13'
---

**JavaScript version**

```js getParam.js
const getParam = (url, param) => new URLSearchParams(new URL(url).search).get(param);
```

**TypeScript version**

```ts getParam.ts
const getParam = (url: string, param: string): string | null => new URLSearchParams(new URL(url).search).get(param);
```

**Examples**

```js examples.js
getParam('http://domain.com?message=hello', 'message'); // 'hello'
```
